/*
Created		26/08/2009
Modified		27/09/2010
Project		CIMa Planning
Model			Main
Company		CPIngredientes
Author		RGM
Version		0.1
Database		MS SQL 2000 
*/

DROP TABLE [grinds_distributions_priorities_versions]
GO
Create table [grinds_distributions_priorities_versions]
(
	[grind_distribution_priority_version_id] Integer Identity NOT NULL,
	[plant_version_id] Integer NOT NULL,
	[corn_type_id] Integer NOT NULL,
	[priority] Tinyint NOT NULL,
Primary Key ([grind_distribution_priority_version_id])
) 
go

DROP TABLE [unloads_settings_versions]
GO
Create table [unloads_settings_versions]
(
	[unload_setting_version_id] Integer Identity NOT NULL,
	[plant_version_id] Integer NOT NULL,
	[corn_type_id] Integer NOT NULL,
	[unload_amount] Decimal(18,4) Default 0 NOT NULL,
	[fixed] Tinyint Default 0 NOT NULL,
Primary Key ([unload_setting_version_id])
) 
go



Alter table [grinds_distributions_priorities_versions] add  foreign key([plant_version_id]) references [plants_versions] ([plant_version_id])  on update no action on delete cascade 
go
Alter table [grinds_distributions_priorities_versions] add  foreign key([corn_type_id]) references [corns_types] ([corn_type_id])  on update no action on delete no action 
go
Alter table [unloads_settings_versions] add  foreign key([plant_version_id]) references [plants_versions] ([plant_version_id])  on update no action on delete cascade 
go
Alter table [unloads_settings_versions] add  foreign key([corn_type_id]) references [corns_types] ([corn_type_id])  on update no action on delete cascade 
go



Set quoted_identifier on
go



Set quoted_identifier off
go


